var s=["province","city"];
var opt0 = new Array();
function change(v){
    var str="0";
    for(i=0;i<v;i++){ str+=("_"+(document.getElementById(s[i]).selectedIndex-1));};
    var ss=document.getElementById(s[v]);
    with(ss){
        length = 0;
        options[0]=new Option(opt0[v],opt0[v]);
        if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v)
        {
            if(dsy.Exists(str)){
                ar = dsy.Items[str];
                for(i=0;i<ar.length;i++)options[length]=new Option(ar[i],ar[i]);
                if(v)options[1].selected = true;
            }
        }
        if(++v<s.length){change(v);}
    }
    var p=$('#province').val();
    var c=$('#city').val();
    if(c.substr(c.length-1,1)=='市'){
        c=c.substr(0,c.length-1);
    }
    var s1=shop[p][c];
    $('#shop').html('');
    if(s1){
        var n=s1.indexOf(',');
        if(n>2){
            s1=s1.substr(0,n)+'</option><option>'+s1.substr(n+1);
        }
        $('#shop').append('<option value="">==请选择==</option><option>'+s1+'</option>');
    }else{
        $('#shop').append('<option value="">==请选择==</option><option value="">暂无经销商</option>');
    }
}

$(document).ready(function (){
    var o1 = document.getElementById('o1').value;
    var o2 = document.getElementById('o2').value;
    if(o1 !='' ){
        opt0 = [o1,o2];
    }else{
        opt0 = ["=请选择=","=请选择="];
    }

});

function cotysetup(){
    for(i=0;i<s.length-1;i++)
    document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
    change(0);
}
cotysetup();